package com.atguigu.exer;

public class ThreadDemo {
    //练习:创建两个分线程，其中一个线程遍历100以内的偶数，另一个遍历100以内的奇数
    public static void main(String[] args) {
        ThreadDemo1 threadDemo1=new ThreadDemo1();
        ThreadDemo2 threadDemo2=new ThreadDemo2();
        threadDemo1.start();
        threadDemo2.start();
        //创建Thread的匿名子类
        new Thread(){
            public void run(){
                for(int i=0;i<100;i++){
                    if((i&1)==1){
                        System.out.println(i+" tmp");
                    }
                }
            }
        }.start();
    }
}
class ThreadDemo1 extends Thread{
    public void run(){
        for(int i=0;i<=100;i++){
            if((i&1)==1){
                System.out.println(i+"  demo1");
            }
        }
    }
}
class ThreadDemo2 extends Thread{
    public void run(){
        for(int i=0;i<=100;i++){
            if((i&0)==0){
                System.out.println(i+"  demo2");
            }
        }
    }
}
